/*
    Project Milestone 3
    by Lorenzo Miori [Lorenzo.Miori@stud-inf.unibz.it,
    Matteo Angriman [Matteo.Angriman@stud-inf.unibz.it],
    Nick Preda [Nicolae.Preda@stud-inf.unibz.it]
*/

package DB;

import static DB.GenericDBInterface.*;
import java.sql.Connection;
import java.util.HashMap;

/**
 * 
 * @author lorenzo
 */
public class AddressDB extends GenericTableInterface {
    
    /* Attribute names to be used in SQL query */
    public static final String ADDRESS_TABLE_NAME = "Address";
    public static final String ADDRESS_ID = "address_id";
    public static final String ADDRESS_STREET = "street_name";
    public static final String ADDRESS_CIVIC_N = "civic_number";
    public static final String ADDRESS_CITY = "city";
    public static final String ADDRESS_STATE = "state";
    public static final String ADDRESS_ZIPCODE = "zip_code";
    public static final String ADDRESS_ORDERING[] = {ADDRESS_ID, ADDRESS_STREET,
                                                ADDRESS_CIVIC_N, ADDRESS_CITY,
                                                ADDRESS_STATE, ADDRESS_ZIPCODE};
    /* Attribute types */
    public static final int[] HOTEL_TYPES = {INT, STRING, STRING, STRING, STRING, INT};
    
    public AddressDB(Connection dbConnection) {
        /* The generic interface wants to know some stuff...
         * Basic datatypes, the elementary attribute names
         */
        super(dbConnection, HOTEL_TYPES, ADDRESS_ID,
                                ADDRESS_TABLE_NAME, ADDRESS_ORDERING);
    }
    
    public static String formatAddress(HashMap<String, String> addrData) {
        return addrData.get(AddressDB.ADDRESS_STREET) + ", " +
               addrData.get(AddressDB.ADDRESS_CIVIC_N) + " " +
               addrData.get(AddressDB.ADDRESS_CITY) + ", " +
               addrData.get(AddressDB.ADDRESS_STATE);
    }
}